import { ContainerModule } from "@theia/core/shared/inversify";
import { RpcConnectionHandler, ConnectionHandler } from "@theia/core";
import { ITestServer, SERVER_PATH } from "../common/test-control";

import { TestServerImpl }  from './test-server';

export default new ContainerModule(bind => {
    bind<ITestServer>(ITestServer).to(TestServerImpl).inSingletonScope();

    bind<ConnectionHandler>(ConnectionHandler).toDynamicValue(ctx =>
        new RpcConnectionHandler<any>(
            SERVER_PATH,
            () => ctx.container.get<ITestServer>(ITestServer)
        )
    ).inSingletonScope();
});
